/*
   Scanner.cpp
   
   Copyright (C) 2006 LinuxOne, Inc. <Republic of korea>

   This library is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as
   published by the Free Software Foundation; either version 2.1
   of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   Lessor General Public License for more details.

   You should have received a copy of the GNU Lessor General Public
   License along with this library; if not, write to the Free Software
   Foundation, inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

   Hyunjin Kim <mgc521@linuxone.co.kr>

   LinuxOne, Inc., hereby disclaims all copylight
   written by Hyunjin Kim, 20 December 2006
*/

#include <services/ScannerService.h>

namespace booyopos
{

namespace services
{

CScannerService::CScannerService()
{
	deviceServiceDescription = "BooyoPOS Barcode Scanner Device";
	deviceServiceVersion = 0;
	physicalDeviceDescription = "Valcretec Barcode Scanner Device";
	physicalDeviceName = "Scanner";
}

CScannerService::~CScannerService()
{
}

/* Capabilities */
int
CScannerService::GetCapPowerReporting()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return capPowerReporting;
	}
	catch(CByException bye)
	{
		throw bye;
	}
}

bool
CScannerService::GetCapStatisticsReporting()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return capStatisticsReporting;
	}
	catch(CByException bye)
	{
		throw bye;
	}
}

bool
CScannerService::GetCapUpdateStatistics()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return capUpdateStatistics;
	}
	catch(CByException bye)
	{
		throw bye;
	}
}

bool
CScannerService::GetCapCompareFirmwareVersion()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return capCompareFirmwareVersion;
	}
	catch(CByException bye)
	{
		throw bye;
	}
}

bool
CScannerService::GetCapUpdateFirmware()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return capUpdateFirmware;
	}
	catch(CByException bye)
	{
		throw bye;
	}
}

/* Properties */
bool
CScannerService::GetAutoDisable()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return autoDisable;
	}
	catch(CByException bye)
	{
		throw bye;
	}
}

void
CScannerService::SetAutoDisable(bool autoDisable)
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		CScannerService::autoDisable = autoDisable;
	}
	catch(CByException bye)
	{
		throw bye;
	}
}

int
CScannerService::GetDataCount()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return dataCount;
	}
	catch(CByException bye)
	{
		throw bye;
	}
}

bool
CScannerService::GetDataEventEnabled()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return dataEventEnabled;
	}
	catch(CByException bye)
	{
		throw bye;
	}
}

void
CScannerService::SetDataEventEnabled(bool dataEventEnabled)
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		CScannerService::dataEventEnabled = dataEventEnabled;
	}
	catch(CByException bye)
	{
		throw bye;
	}
}

bool
CScannerService::GetDecodeData()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return decodeData;
	}
	catch(CByException bye)
	{
		throw bye;
	}
}

void
CScannerService::SetDecodeData(bool decodeData)
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		CScannerService::decodeData = decodeData;
	}
	catch(CByException bye)
	{
		throw bye;
	}
}

char*
CScannerService::GetScanData()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return scanData;
	}
	catch(CByException bye)
	{
		throw bye;
	}
}

char*
CScannerService::GetScanDataLabel()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return scanDataLabel;
	}
	catch(CByException bye)
	{
		throw bye;
	}
}

int
CScannerService::GetScanDataType()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return GetScanDataType();
	}
	catch(CByException bye)
	{
		throw bye;
	}
}

int
CScannerService::GetPowerNotify()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return GetPowerNotify();
	}
	catch(CByException bye)
	{
		throw bye;
	}
}

void
CScannerService::SetPowerNotify(int powerNotice)
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		CScannerService::powerNotice = powerNotice;
	}
	catch(CByException bye)
	{
		throw bye;
	}
}

int
CScannerService::GetPowerState()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return powerState;
	}
	catch(CByException bye)
	{
		throw bye;
	}
}

/* Method */
void
CScannerService::ClearInput()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		/* TO DO */
	}
	catch(CByException bye)
	{
		throw bye;
	}
}

void
CScannerService::ClearInputProperties()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		/* TO DO */
	}
	catch(CByException bye)
	{
		throw bye;
	}
}

/* statistics */
void
CScannerService::ResetStatistics(std::string statisticsBuffer)
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		/* TO DO */
	}
	catch(CByException bye)
	{
		throw bye;
	}
}

void
CScannerService::RetrieveStatistics(std::string statisticsBuffer[])
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		/* TO DO */
	}
	catch(CByException bye)
	{
		throw bye;
	}
}

void
CScannerService::UpdateStatistics(std::string statisticsBuffer)
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		/* TO DO */
	}
	catch(CByException bye)
	{
		throw bye;
	}
}

void
CScannerService::CompareFirmwareVersion(std::string firmwareFileName, int* result)
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		/* TO DO */
	}
	catch(CByException bye)
	{
		throw bye;
	}
}

void
CScannerService::UpdateFirmware(std::string firmwareFileName)
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		/* TO DO */
	}
	catch(CByException bye)
	{
		throw bye;
	}
}

} // namespace services

} // namespace booyopos
